Gatik Rajput.
Published on

Upgrading AWS Lambda to Node@18 Runtime Checklist

Authors
  • avatar
    Name
    Gatik Rajput
    Twitter

Upgrading AWS Lambda to Node@18 Runtime Checklist

So you have AWS Lambda in production, using Node.js 14 or 16, and you're looking to upgrade to the new Node@18 Runtimes? Here’s a step-by-step checklist to guide you through the process:

Objective

We aim to provide readers with a clear checklist for upgrading their AWS Lambda functions to the Node@18 runtime.

Checklist

  1. Upgrade Your Local NodeJS Runtime

    • Upgrade to Node.js version 18, either by downloading directly from nodejs.org or using nvm. As of the time of writing, Node.js 18.14.2 is the LTS version.
  2. Update package-lock.json

    • Run npm install to ensure your package-lock.json reflects the new Node.js version.
  3. Add Engines Field to package.json

    • Add an engines field to your package.json to enforce the use of Node.js 18 for your project.
    "engines": {
      "node": ">=18.14.2"
    }
    
    
  4. Update AWS Lambda Configuration

    • Modify your AWS Lambda configuration to use the nodejs18.x runtime. If using CloudFormation, update "Runtime": "nodejs18.x".
  5. Update CI/CD Pipelines

    • Adjust your CI/CD pipelines to build with Node.js version 18.14.2.
  6. Webpack Considerations

    • If using Webpack, ensure compatibility with Node@18. Using webpack 5.75 has been found effective for projects targeting Node@18.
  7. Upgrade aws-sdk to Version 3 (Optional but recommended)

    • Consider upgrading from aws-sdk v2 to v3, which comes built-in with the AWS Lambda nodejs18.x runtime (version 3.188.0). Search for @aws-sdk/client- on npm to find v3 packages.
    {
      externals: {
        "@aws-sdk/client-ses": "@aws-sdk/client-ses"
      }
    }
    
    
  8. Staying with aws-sdk V2

    • If you choose to stay with aws-sdk v2, you should bundle it with your code to ensure compatibility with your AWS Lambda function.
  9. End-to-End Testing

    • After upgrading and deploying your AWS Lambda function with Node@18, perform comprehensive end-to-end testing to verify functionality and ensure no issues arise.

By following this checklist, you can successfully upgrade your AWS Lambda functions to utilize the latest Node@18 runtime, leveraging enhanced features and performance improvements while ensuring smooth operation in production.